import Foundation

@available(iOS 2.0, *)
open class UIView : UIResponder,
                    NSCoding,
                    UIAppearance,
                    UIAppearanceContainer,
                    UIDynamicItem,
                    UITraitEnvironment,
                    UICoordinateSpace,
                    UIFocusItem,
                    UIFocusItemContainer,
                    CALayerDelegate {

    open class var layerClass: AnyClass { get }

    public init(frame: CGRect)

    public init?(coder: NSCoder)

    // 是否启用了用户交互
    open var isUserInteractionEnabled: Bool

    // 标签号
    open var tag: Int

    // 图层
    open var layer: CALayer { get }

    @available(iOS 9.0, *)
    open var canBecomeFocused: Bool { get }

    @available(iOS 9.0, *)
    open var isFocused: Bool { get }

    /// The identifier of the focus group that this view belongs to. If this is nil, subviews inherit their superview's focus group.
    @available(iOS 14.0, *)
    open var focusGroupIdentifier: String?

    /// The priority this item has in its focus group. The higher the priority, the more likely it is to get picked when focus moves into this group.
    /// Note: this method can only be used to increase an item's priority, not decrease it. For example if an item is currently selected, the actual priority of this item will be determined by MAX(focusGroupPriority, UIFocusGroupPrioritySelected).
    @available(iOS 15.0, *)
    open var focusGroupPriority: UIFocusGroupPriority

    /// Describes a visual effect to apply when this item is focused. If this property is nil no effect will be applied when this view becomes focused.
    @available(iOS 15.0, *)
    @NSCopying open var focusEffect: UIFocusEffect?

    @available(iOS 9.0, *)
    open var semanticContentAttribute: UISemanticContentAttribute

    @available(iOS 9.0, *)
    open class func userInterfaceLayoutDirection(for attribute: UISemanticContentAttribute) -> UIUserInterfaceLayoutDirection

    @available(iOS 10.0, *)
    open class func userInterfaceLayoutDirection(for semanticContentAttribute: UISemanticContentAttribute, relativeTo layoutDirection: UIUserInterfaceLayoutDirection) -> UIUserInterfaceLayoutDirection

    @available(iOS 10.0, *)
    open var effectiveUserInterfaceLayoutDirection: UIUserInterfaceLayoutDirection { get }
}

extension UIView {

    @available(swift 5.1)
    @available(iOS 15, tvOS 15, *)
    @propertyWrapper public struct Invalidating<Value, InvalidationType> where Value : Equatable, InvalidationType : UIViewInvalidating {

        public init(wrappedValue: Value, _ invalidation: InvalidationType)

        public init<InvalidationType1, InvalidationType2>(wrappedValue: Value, _ invalidation1: InvalidationType1, _ invalidation2: InvalidationType2) where InvalidationType == UIView.Invalidations.Tuple<InvalidationType1, InvalidationType2>, InvalidationType1 : UIViewInvalidating, InvalidationType2 : UIViewInvalidating

        public init<InvalidationType1, InvalidationType2, InvalidationType3>(wrappedValue: Value, _ invalidation1: InvalidationType1, _ invalidation2: InvalidationType2, _ invalidation3: InvalidationType3) where InvalidationType == UIView.Invalidations.Tuple<UIView.Invalidations.Tuple<InvalidationType1, InvalidationType2>, InvalidationType3>, InvalidationType1 : UIViewInvalidating, InvalidationType2 : UIViewInvalidating, InvalidationType3 : UIViewInvalidating

        public init<InvalidationType1, InvalidationType2, InvalidationType3, InvalidationType4>(wrappedValue: Value, _ invalidation1: InvalidationType1, _ invalidation2: InvalidationType2, _ invalidation3: InvalidationType3, _ invalidation4: InvalidationType4) where InvalidationType == UIView.Invalidations.Tuple<UIView.Invalidations.Tuple<InvalidationType1, InvalidationType2>, UIView.Invalidations.Tuple<InvalidationType3, InvalidationType4>>, InvalidationType1 : UIViewInvalidating, InvalidationType2 : UIViewInvalidating, InvalidationType3 : UIViewInvalidating, InvalidationType4 : UIViewInvalidating

        public init<InvalidationType1, InvalidationType2, InvalidationType3, InvalidationType4, InvalidationType5>(wrappedValue: Value, _ invalidation1: InvalidationType1, _ invalidation2: InvalidationType2, _ invalidation3: InvalidationType3, _ invalidation4: InvalidationType4, _ invalidation5: InvalidationType5) where InvalidationType == UIView.Invalidations.Tuple<UIView.Invalidations.Tuple<UIView.Invalidations.Tuple<InvalidationType1, InvalidationType2>, UIView.Invalidations.Tuple<InvalidationType3, InvalidationType4>>, InvalidationType5>, InvalidationType1 : UIViewInvalidating, InvalidationType2 : UIViewInvalidating, InvalidationType3 : UIViewInvalidating, InvalidationType4 : UIViewInvalidating, InvalidationType5 : UIViewInvalidating

        public init<InvalidationType1, InvalidationType2, InvalidationType3, InvalidationType4, InvalidationType5, InvalidationType6>(wrappedValue: Value, _ invalidation1: InvalidationType1, _ invalidation2: InvalidationType2, _ invalidation3: InvalidationType3, _ invalidation4: InvalidationType4, _ invalidation5: InvalidationType5, _ invalidation6: InvalidationType6) where InvalidationType == UIView.Invalidations.Tuple<UIView.Invalidations.Tuple<UIView.Invalidations.Tuple<InvalidationType1, InvalidationType2>, UIView.Invalidations.Tuple<InvalidationType3, InvalidationType4>>, UIView.Invalidations.Tuple<InvalidationType5, InvalidationType6>>, InvalidationType1 : UIViewInvalidating, InvalidationType2 : UIViewInvalidating, InvalidationType3 : UIViewInvalidating, InvalidationType4 : UIViewInvalidating, InvalidationType5 : UIViewInvalidating, InvalidationType6 : UIViewInvalidating

        public init<InvalidationType1, InvalidationType2, InvalidationType3, InvalidationType4, InvalidationType5, InvalidationType6, InvalidationType7>(wrappedValue: Value, _ invalidation1: InvalidationType1, _ invalidation2: InvalidationType2, _ invalidation3: InvalidationType3, _ invalidation4: InvalidationType4, _ invalidation5: InvalidationType5, _ invalidation6: InvalidationType6, _ invalidation7: InvalidationType7) where InvalidationType == UIView.Invalidations.Tuple<UIView.Invalidations.Tuple<UIView.Invalidations.Tuple<InvalidationType1, InvalidationType2>, UIView.Invalidations.Tuple<InvalidationType3, InvalidationType4>>, UIView.Invalidations.Tuple<UIView.Invalidations.Tuple<InvalidationType5, InvalidationType6>, InvalidationType7>>, InvalidationType1 : UIViewInvalidating, InvalidationType2 : UIViewInvalidating, InvalidationType3 : UIViewInvalidating, InvalidationType4 : UIViewInvalidating, InvalidationType5 : UIViewInvalidating, InvalidationType6 : UIViewInvalidating, InvalidationType7 : UIViewInvalidating

        public init<InvalidationType1, InvalidationType2, InvalidationType3, InvalidationType4, InvalidationType5, InvalidationType6, InvalidationType7, InvalidationType8>(wrappedValue: Value, _ invalidation1: InvalidationType1, _ invalidation2: InvalidationType2, _ invalidation3: InvalidationType3, _ invalidation4: InvalidationType4, _ invalidation5: InvalidationType5, _ invalidation6: InvalidationType6, _ invalidation7: InvalidationType7, _ invalidation8: InvalidationType8) where InvalidationType == UIView.Invalidations.Tuple<UIView.Invalidations.Tuple<UIView.Invalidations.Tuple<InvalidationType1, InvalidationType2>, UIView.Invalidations.Tuple<InvalidationType3, InvalidationType4>>, UIView.Invalidations.Tuple<UIView.Invalidations.Tuple<InvalidationType5, InvalidationType6>, UIView.Invalidations.Tuple<InvalidationType7, InvalidationType8>>>, InvalidationType1 : UIViewInvalidating, InvalidationType2 : UIViewInvalidating, InvalidationType3 : UIViewInvalidating, InvalidationType4 : UIViewInvalidating, InvalidationType5 : UIViewInvalidating, InvalidationType6 : UIViewInvalidating, InvalidationType7 : UIViewInvalidating, InvalidationType8 : UIViewInvalidating

        public init<InvalidationType1, InvalidationType2, InvalidationType3, InvalidationType4, InvalidationType5, InvalidationType6, InvalidationType7, InvalidationType8, InvalidationType9>(wrappedValue: Value, _ invalidation1: InvalidationType1, _ invalidation2: InvalidationType2, _ invalidation3: InvalidationType3, _ invalidation4: InvalidationType4, _ invalidation5: InvalidationType5, _ invalidation6: InvalidationType6, _ invalidation7: InvalidationType7, _ invalidation8: InvalidationType8, _ invalidation9: InvalidationType9) where InvalidationType == UIView.Invalidations.Tuple<UIView.Invalidations.Tuple<UIView.Invalidations.Tuple<UIView.Invalidations.Tuple<InvalidationType1, InvalidationType2>, UIView.Invalidations.Tuple<InvalidationType3, InvalidationType4>>, UIView.Invalidations.Tuple<UIView.Invalidations.Tuple<InvalidationType5, InvalidationType6>, UIView.Invalidations.Tuple<InvalidationType7, InvalidationType8>>>, InvalidationType9>, InvalidationType1 : UIViewInvalidating, InvalidationType2 : UIViewInvalidating, InvalidationType3 : UIViewInvalidating, InvalidationType4 : UIViewInvalidating, InvalidationType5 : UIViewInvalidating, InvalidationType6 : UIViewInvalidating, InvalidationType7 : UIViewInvalidating, InvalidationType8 : UIViewInvalidating, InvalidationType9 : UIViewInvalidating

        public init<InvalidationType1, InvalidationType2, InvalidationType3, InvalidationType4, InvalidationType5, InvalidationType6, InvalidationType7, InvalidationType8, InvalidationType9, InvalidationType10>(wrappedValue: Value, _ invalidation1: InvalidationType1, _ invalidation2: InvalidationType2, _ invalidation3: InvalidationType3, _ invalidation4: InvalidationType4, _ invalidation5: InvalidationType5, _ invalidation6: InvalidationType6, _ invalidation7: InvalidationType7, _ invalidation8: InvalidationType8, _ invalidation9: InvalidationType9, _ invalidation10: InvalidationType10) where InvalidationType == UIView.Invalidations.Tuple<UIView.Invalidations.Tuple<UIView.Invalidations.Tuple<UIView.Invalidations.Tuple<InvalidationType1, InvalidationType2>, UIView.Invalidations.Tuple<InvalidationType3, InvalidationType4>>, UIView.Invalidations.Tuple<UIView.Invalidations.Tuple<InvalidationType5, InvalidationType6>, UIView.Invalidations.Tuple<InvalidationType7, InvalidationType8>>>, UIView.Invalidations.Tuple<InvalidationType9, InvalidationType10>>, InvalidationType1 : UIViewInvalidating, InvalidationType2 : UIViewInvalidating, InvalidationType3 : UIViewInvalidating, InvalidationType4 : UIViewInvalidating, InvalidationType5 : UIViewInvalidating, InvalidationType6 : UIViewInvalidating, InvalidationType7 : UIViewInvalidating, InvalidationType8 : UIViewInvalidating, InvalidationType9 : UIViewInvalidating, InvalidationType10 : UIViewInvalidating
    }
}

extension UIView {
    
    // 框
    open var frame: CGRect
    
    // 范围
    open var bounds: CGRect

    // 中心点
    open var center: CGPoint

    // 变形值
    open var transform: CGAffineTransform

    @available(iOS 13.0, *)
    // 3D变形值
    open var transform3D: CATransform3D

    @available(iOS 4.0, *)
    open var contentScaleFactor: CGFloat

    open var isMultipleTouchEnabled: Bool

    open var isExclusiveTouch: Bool

    /**
     命中测试(点击测试), 点击的是哪个视图
     */
    open func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView?

    /**
     点击的位置是否在区域内
     */
    open func point(inside point: CGPoint, with event: UIEvent?) -> Bool

    /**
     坐标系转换
     */
    open func convert(_ point: CGPoint, to view: UIView?) -> CGPoint

    /**
     坐标系转换
     */
    open func convert(_ point: CGPoint, from view: UIView?) -> CGPoint

    /**
     坐标系转换
     */
    open func convert(_ rect: CGRect, to view: UIView?) -> CGRect

    /**
     坐标系转换
     */
    open func convert(_ rect: CGRect, from view: UIView?) -> CGRect

    open var autoresizesSubviews: Bool

    open var autoresizingMask: UIView.AutoresizingMask
    
    // 可容纳的尺寸
    open func sizeThatFits(_ size: CGSize) -> CGSize
    
    // 使用可容纳的尺寸
    open func sizeToFit()
}
extension UIView {

    // 父容器
    open var superview: UIView? { get }
// 子容器
    open var subviews: [UIView] { get }
// 属于的窗口
    open var window: UIWindow? { get }
// 从父控件移除
    open func removeFromSuperview()

    // 在index位置 插入视图
    open func insertSubview(_ view: UIView, at index: Int)

// 交换子视图
    open func exchangeSubview(at index1: Int, withSubviewAt index2: Int)

    // 添加子视图(在最上面)
    open func addSubview(_ view: UIView)

    // 在siblingSubview的下面插入子视图
    open func insertSubview(_ view: UIView, belowSubview siblingSubview: UIView)
    
    // 在siblingSubview的上面插入子视图
    open func insertSubview(_ view: UIView, aboveSubview siblingSubview: UIView)
    
    // 将UIView显示在父类的最前面
    open func bringSubviewToFront(_ view: UIView)
    
    // 将UIView显示在父类的最后面
    open func sendSubviewToBack(_ view: UIView)

    /// 添加视图 生命周期
    
    open func didAddSubview(_ subview: UIView)

    open func willRemoveSubview(_ subview: UIView)

    open func willMove(toSuperview newSuperview: UIView?)

    open func didMoveToSuperview()

    open func willMove(toWindow newWindow: UIWindow?)

    open func didMoveToWindow()

    open func isDescendant(of view: UIView) -> Bool

    // 根据tag查找子视图
    open func viewWithTag(_ tag: Int) -> UIView?

    // 标记需要布局
    open func setNeedsLayout()

    // 需要强制布局
    open func layoutIfNeeded()

    // 布局子视图
    open func layoutSubviews()

    @available(iOS 8.0, *)
    open var layoutMargins: UIEdgeInsets

    @available(iOS 11.0, *)
    open var directionalLayoutMargins: NSDirectionalEdgeInsets

    @available(iOS 8.0, *)
    open var preservesSuperviewLayoutMargins: Bool

    @available(iOS 11.0, *)
    open var insetsLayoutMarginsFromSafeArea: Bool

    @available(iOS 8.0, *)
    open func layoutMarginsDidChange()

    @available(iOS 11.0, *)
    open var safeAreaInsets: UIEdgeInsets { get }

    @available(iOS 11.0, *)
    open func safeAreaInsetsDidChange()

    @available(iOS 9.0, *)
    open var layoutMarginsGuide: UILayoutGuide { get }

    /// This content guide provides a layout area that you can use to place text and related content whose width should generally be constrained to a size that is easy for the user to read. This guide provides a centered region that you can place content within to get this behavior for this view.
    @available(iOS 9.0, *)
    open var readableContentGuide: UILayoutGuide { get }

    @available(iOS 11.0, *)
    open var safeAreaLayoutGuide: UILayoutGuide { get }

    /// Follows the keyboard when on screen and docked. When the keyboard is offscreen or undocked, keyboardLayoutGuide.topAnchor matches the view's safeAreaLayoutGuide.bottomAnchor.
    @available(iOS 15.0, *)
    open var keyboardLayoutGuide: UIKeyboardLayoutGuide { get }
}
extension UIView {

    // 重绘
    open func draw(_ rect: CGRect)

    // 标记需要重绘
    open func setNeedsDisplay()

    // 标记需要重绘 大小的框
    open func setNeedsDisplay(_ rect: CGRect)

    // 根据范围裁剪
    open var clipsToBounds: Bool

    // 背景色
    @NSCopying open var backgroundColor: UIColor?

    // 透明度
    open var alpha: CGFloat

    // 使不透明
    open var isOpaque: Bool

    open var clearsContextBeforeDrawing: Bool

    // 隐藏
    open var isHidden: Bool

    // 内容显示模式
    open var contentMode: UIView.ContentMode

    @available(iOS 8.0, *)
    // 遮盖
    open var mask: UIView?

    @available(iOS 7.0, *)
    // 底色
    open var tintColor: UIColor!

    @available(iOS 7.0, *)
    open var tintAdjustmentMode: UIView.TintAdjustmentMode

    @available(iOS 7.0, *)
    open func tintColorDidChange()
}
extension UIView {

    open class func setAnimationsEnabled(_ enabled: Bool)

    open class var areAnimationsEnabled: Bool { get }

    @available(iOS 7.0, *)
    open class func performWithoutAnimation(_ actionsWithoutAnimation: () -> Void)

    @available(iOS 9.0, *)
    open class var inheritedAnimationDuration: TimeInterval { get }
}
extension UIView {

    @available(iOS 4.0, *)
    open class func animate(withDuration duration: TimeInterval, delay: TimeInterval, options: UIView.AnimationOptions = [], animations: @escaping () -> Void, completion: ((Bool) -> Void)? = nil)

    @available(iOS 4.0, *)
    open class func animate(withDuration duration: TimeInterval, animations: @escaping () -> Void, completion: ((Bool) -> Void)? = nil)

    @available(iOS 4.0, *)
    open class func animate(withDuration duration: TimeInterval, animations: @escaping () -> Void)

    @available(iOS 7.0, *)
    open class func animate(withDuration duration: TimeInterval, delay: TimeInterval, usingSpringWithDamping dampingRatio: CGFloat, initialSpringVelocity velocity: CGFloat, options: UIView.AnimationOptions = [], animations: @escaping () -> Void, completion: ((Bool) -> Void)? = nil)

    @available(iOS 4.0, *)
    open class func transition(with view: UIView, duration: TimeInterval, options: UIView.AnimationOptions = [], animations: (() -> Void)?, completion: ((Bool) -> Void)? = nil)

    @available(iOS 4.0, *)
    open class func transition(from fromView: UIView, to toView: UIView, duration: TimeInterval, options: UIView.AnimationOptions = [], completion: ((Bool) -> Void)? = nil)

    @available(iOS 7.0, *)
    open class func perform(_ animation: UIView.SystemAnimation, on views: [UIView], options: UIView.AnimationOptions = [], animations parallelAnimations: (() -> Void)?, completion: ((Bool) -> Void)? = nil)

    @available(iOS 13.0, *)
    open class func modifyAnimations(withRepeatCount count: CGFloat, autoreverses: Bool, animations: () -> Void)
}
extension UIView {

    @available(iOS 7.0, *)
    open class func animateKeyframes(withDuration duration: TimeInterval, delay: TimeInterval, options: UIView.KeyframeAnimationOptions = [], animations: @escaping () -> Void, completion: ((Bool) -> Void)? = nil)

    @available(iOS 7.0, *)
    open class func animateKeyframes(withDuration duration: TimeInterval, delay: TimeInterval, options: UIView.KeyframeAnimationOptions = [], animations: @escaping () -> Void) async -> Bool

    @available(iOS 7.0, *)
    open class func addKeyframe(withRelativeStartTime frameStartTime: Double, relativeDuration frameDuration: Double, animations: @escaping () -> Void)
}

// MARK: - 手势
extension UIView {

    @available(iOS 3.2, *)
    open var gestureRecognizers: [UIGestureRecognizer]?

    @available(iOS 3.2, *)
    open func addGestureRecognizer(_ gestureRecognizer: UIGestureRecognizer)

    @available(iOS 3.2, *)
    open func removeGestureRecognizer(_ gestureRecognizer: UIGestureRecognizer)

    @available(iOS 6.0, *)
    open func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool
}
extension UIView {

    /** Begins applying `effect` to the receiver. The effect's emitted keyPath/value pairs will be
        applied to the view's presentation layer.
     
        Animates the transition to the motion effect's values using the present UIView animation
        context. */
    @available(iOS 7.0, *)
    open func addMotionEffect(_ effect: UIMotionEffect)

    /** Stops applying `effect` to the receiver. Any affected presentation values will animate to
        their post-removal values using the present UIView animation context. */
    @available(iOS 7.0, *)
    open func removeMotionEffect(_ effect: UIMotionEffect)

    @available(iOS 7.0, *)
    open var motionEffects: [UIMotionEffect]
}
extension NSLayoutConstraint {

    public enum Axis : Int {

        case horizontal = 0

        case vertical = 1
    }
}

// MARK: - 自动布局
extension UIView {

    @available(iOS 6.0, *)
    open var constraints: [NSLayoutConstraint] { get }

    @available(iOS 6.0, *)
    open func addConstraint(_ constraint: NSLayoutConstraint)

    @available(iOS 6.0, *)
    open func addConstraints(_ constraints: [NSLayoutConstraint])

    @available(iOS 6.0, *)
    open func removeConstraint(_ constraint: NSLayoutConstraint)

    @available(iOS 6.0, *)
    open func removeConstraints(_ constraints: [NSLayoutConstraint])
}
extension UIView {

    @available(iOS 6.0, *)
    open func updateConstraintsIfNeeded()

    @available(iOS 6.0, *)
    open func updateConstraints()

    @available(iOS 6.0, *)
    open func needsUpdateConstraints() -> Bool

    @available(iOS 6.0, *)
    open func setNeedsUpdateConstraints()
}
extension UIView {

    @available(iOS 6.0, *)
    open var translatesAutoresizingMaskIntoConstraints: Bool

    @available(iOS 6.0, *)
    open class var requiresConstraintBasedLayout: Bool { get }
}
extension UIView {

    @available(iOS 6.0, *)
    open func alignmentRect(forFrame frame: CGRect) -> CGRect

    @available(iOS 6.0, *)
    open func frame(forAlignmentRect alignmentRect: CGRect) -> CGRect

    @available(iOS 6.0, *)
    open var alignmentRectInsets: UIEdgeInsets { get }

    @available(iOS, introduced: 6.0, deprecated: 9.0, message: "Override -viewForFirstBaselineLayout or -viewForLastBaselineLayout as appropriate, instead")
    open func forBaselineLayout() -> UIView

    @available(iOS 9.0, *)
    open var forFirstBaselineLayout: UIView { get }

    @available(iOS 9.0, *)
    open var forLastBaselineLayout: UIView { get }

    @available(iOS 6.0, *)
    open var intrinsicContentSize: CGSize { get }

    @available(iOS 6.0, *)
    open func invalidateIntrinsicContentSize()

    /**
     约束(不想变大约束)
     -  如果组件的此属性优先级比另一个组件此属性优先级高的话,
     -  那么这个组件就保持不变, 另一个可以在需要拉伸的时候拉伸.
     ```
     水平有 label1, label2,
     如果:
     -  label1 在左侧, label2 在右侧,
     -  label1 + label2 的内容不够填充父控件, 想必有一个会被拉伸,
     如果:
     -  label2 被拉伸, 但是功能是不让其拉伸,
     那么:
     lable2.属性值 > lable1.属性值
     lable1.属性值 = 100
     lable2.属性值 = 800
     lable2 不会被拉伸, lable1 会填充其余部分
     ```
     */
    open func contentHuggingPriority(for axis: NSLayoutConstraint.Axis) -> UILayoutPriority
    open func setContentHuggingPriority(_ priority: UILayoutPriority, for axis: NSLayoutConstraint.Axis)

    /**
     内容抗压缩优先级
     -  值越大, 表示视图越难被压缩
     ```
     水平有 label1, label2,
     如果:
     -  label1 在左侧, label2 在右侧,
     -  label1 + label2 的内容超出父控件, 想必有一个会被压缩,
     如果:
     -  label2 被压缩, 但是功能是不让其压缩,
     那么:
     lable2.属性值 > lable1.属性值
     lable1.属性值 = 100
     lable2.属性值 = 800
     lable2 不会被压缩, lable1 多余部分会被压缩
     ```
     */
    open func contentCompressionResistancePriority(for axis: NSLayoutConstraint.Axis) -> UILayoutPriority
    open func setContentCompressionResistancePriority(_ priority: UILayoutPriority, for axis: NSLayoutConstraint.Axis)
}

extension UIView {

    /* The size fitting most closely to targetSize in which the receiver's subtree can be laid out while optimally satisfying the constraints. If you want the smallest possible size, pass UILayoutFittingCompressedSize; for the largest possible size, pass UILayoutFittingExpandedSize.
     Also see the comment for UILayoutPriorityFittingSizeLevel.
     */
    @available(iOS 6.0, *)
    open func systemLayoutSizeFitting(_ targetSize: CGSize) -> CGSize // Equivalent to sending -systemLayoutSizeFittingSize:withHorizontalFittingPriority:verticalFittingPriority: with UILayoutPriorityFittingSizeLevel for both priorities.

    @available(iOS 8.0, *)
    open func systemLayoutSizeFitting(_ targetSize: CGSize, withHorizontalFittingPriority horizontalFittingPriority: UILayoutPriority, verticalFittingPriority: UILayoutPriority) -> CGSize
}

extension UIView {

    
    /* UILayoutGuide objects owned by the receiver.
     */
    @available(iOS 9.0, *)
    open var layoutGuides: [UILayoutGuide] { get }

    
    /* Adds layoutGuide to the receiver, passing the receiver in -setOwningView: to layoutGuide.
     */
    @available(iOS 9.0, *)
    open func addLayoutGuide(_ layoutGuide: UILayoutGuide)

    
    /* Removes layoutGuide from the receiver, passing nil in -setOwningView: to layoutGuide.
     */
    @available(iOS 9.0, *)
    open func removeLayoutGuide(_ layoutGuide: UILayoutGuide)
}

extension UIView {

    /* Constraint creation conveniences. See NSLayoutAnchor.h for details.
     */
    @available(iOS 9.0, *)
    open var leadingAnchor: NSLayoutXAxisAnchor { get }

    @available(iOS 9.0, *)
    open var trailingAnchor: NSLayoutXAxisAnchor { get }

    @available(iOS 9.0, *)
    open var leftAnchor: NSLayoutXAxisAnchor { get }

    @available(iOS 9.0, *)
    open var rightAnchor: NSLayoutXAxisAnchor { get }

    @available(iOS 9.0, *)
    open var topAnchor: NSLayoutYAxisAnchor { get }

    @available(iOS 9.0, *)
    open var bottomAnchor: NSLayoutYAxisAnchor { get }

    @available(iOS 9.0, *)
    open var widthAnchor: NSLayoutDimension { get }

    @available(iOS 9.0, *)
    open var heightAnchor: NSLayoutDimension { get }

    @available(iOS 9.0, *)
    open var centerXAnchor: NSLayoutXAxisAnchor { get }

    @available(iOS 9.0, *)
    open var centerYAnchor: NSLayoutYAxisAnchor { get }

    @available(iOS 9.0, *)
    open var firstBaselineAnchor: NSLayoutYAxisAnchor { get }

    @available(iOS 9.0, *)
    open var lastBaselineAnchor: NSLayoutYAxisAnchor { get }
}

// Debugging

/* Everything in this section should be used in debugging only, never in shipping code.  These methods may not exist in the future - no promises.
 */
extension UIView {

    
    /* This returns a list of all the constraints that are affecting the current location of the receiver.  The constraints do not necessarily involve the receiver, they may affect the frame indirectly.
     Pass UILayoutConstraintAxisHorizontal for the constraints affecting [self center].x and CGRectGetWidth([self bounds]), and UILayoutConstraintAxisVertical for the constraints affecting[self center].y and CGRectGetHeight([self bounds]).
     */
    @available(iOS 6.0, *)
    open func constraintsAffectingLayout(for axis: NSLayoutConstraint.Axis) -> [NSLayoutConstraint]

    
    /* If there aren't enough constraints in the system to uniquely determine layout, we say the layout is ambiguous.  For example, if the only constraint in the system was x = y + 100, then there are lots of different possible values for x and y.  This situation is not automatically detected by UIKit, due to performance considerations and details of the algorithm used for layout.
     The symptom of ambiguity is that views sometimes jump from place to place, or possibly are just in the wrong place.
     -hasAmbiguousLayout runs a check for whether there is another center and bounds the receiver could have that could also satisfy the constraints.
     -exerciseAmbiguousLayout does more.  It randomly changes the view layout to a different valid layout.  Making the UI jump back and forth can be helpful for figuring out where you're missing a constraint.
     */
    @available(iOS 6.0, *)
    open var hasAmbiguousLayout: Bool { get }

    
    @available(iOS 6.0, *)
    open func exerciseAmbiguityInLayout()
}

/* Everything in this section should be used in debugging only, never in shipping code.  These methods may not exist in the future - no promises.
 */
extension UILayoutGuide {

    
    /* This returns a list of all the constraints that are affecting the current location of the receiver.  The constraints do not necessarily involve the receiver, they may affect the frame indirectly.
     Pass UILayoutConstraintAxisHorizontal for the constraints affecting [self center].x and CGRectGetWidth([self bounds]), and UILayoutConstraintAxisVertical for the constraints affecting[self center].y and CGRectGetHeight([self bounds]).
     */
    @available(iOS 10.0, *)
    open func constraintsAffectingLayout(for axis: NSLayoutConstraint.Axis) -> [NSLayoutConstraint]

    
    /* If there aren't enough constraints in the system to uniquely determine layout, we say the layout is ambiguous.  For example, if the only constraint in the system was x = y + 100, then there are lots of different possible values for x and y.  This situation is not automatically detected by UIKit, due to performance considerations and details of the algorithm used for layout.
     The symptom of ambiguity is that views sometimes jump from place to place, or possibly are just in the wrong place.
     -hasAmbiguousLayout runs a check for whether there is another center and bounds the receiver could have that could also satisfy the constraints.
     */
    @available(iOS 10.0, *)
    open var hasAmbiguousLayout: Bool { get }
}

extension UIView {

    @available(iOS 6.0, *)
    open var restorationIdentifier: String?

    @available(iOS 6.0, *)
    open func encodeRestorableState(with coder: NSCoder)

    @available(iOS 6.0, *)
    open func decodeRestorableState(with coder: NSCoder)
}

extension UIView {

    /*
    * When requesting a snapshot, 'afterUpdates' defines whether the snapshot is representative of what's currently on screen or if you wish to include any recent changes before taking the snapshot.
     
     If called during layout from a committing transaction, snapshots occurring after the screen updates will include all changes made, regardless of when the snapshot is taken and the changes are made. For example:
     
         - (void)layoutSubviews {
             UIView *snapshot = [self snapshotViewAfterScreenUpdates:YES];
             self.alpha = 0.0;
         }
     
     The snapshot will appear to be empty since the change in alpha will be captured by the snapshot. If you need to animate the view during layout, animate the snapshot instead.
    
    * Creating snapshots from existing snapshots (as a method to duplicate, crop or create a resizable variant) is supported. In cases where many snapshots are needed, creating a snapshot from a common superview and making subsequent snapshots from it can be more performant. Please keep in mind that if 'afterUpdates' is YES, the original snapshot is committed and any changes made to it, not the view originally snapshotted, will be included.
     */
    @available(iOS 7.0, *)
    open func snapshotView(afterScreenUpdates afterUpdates: Bool) -> UIView?

    @available(iOS 7.0, *)
    open func resizableSnapshotView(from rect: CGRect, afterScreenUpdates afterUpdates: Bool, withCapInsets capInsets: UIEdgeInsets) -> UIView? // Resizable snapshots will default to stretching the center

    // Use this method to render a snapshot of the view hierarchy into the current context. Returns NO if the snapshot is missing image data, YES if the snapshot is complete. Calling this method from layoutSubviews while the current transaction is committing will capture what is currently displayed regardless if afterUpdates is YES.
    @available(iOS 7.0, *)
    open func drawHierarchy(in rect: CGRect, afterScreenUpdates afterUpdates: Bool) -> Bool
}

extension UIView {

    
    /* Set `overrideUserInterfaceStyle` to cause this view and its subviews to have a specific `UIUserInterfaceStyle`.
     * Reading this property does not return the current `UIUserInterfaceStyle`. Use `traitCollection.userInterfaceStyle` instead.
     *
     * Whenever possible, use the `overrideUserInterfaceStyle` property on `UIViewController` instead.
     *
     * Use this property only when:
     * - You want a particular style on a single view or small view hierarchy.
     * - You want a particular style on an entire `UIWindow` and its view controllers and presentations,
     *   but don't want to force your entire application to have that style.
     *
     *  (If you do want your entire application to have a certain style, don't use this, but instead
     *   set the `UIUserInterfaceStyle" key in your Info.plist.)
     *
     * When set on an ordinary `UIView`:
     * - This property affects only the traits of this view and its subviews.
     * - It does not affect any view controllers, or any subviews that are owned by different view controllers.
     *
     * When set on a `UIWindow`:
     * - This property affects the `rootViewController` and thus the entire view controller and view hierarchy.
     * - It also affects presentations that happen inside the window.
     */
    @available(iOS 13.0, *)
    open var overrideUserInterfaceStyle: UIUserInterfaceStyle
}

extension UIView {

    
    
    /// Specify content size category limits. Setting one or both of these properties will limit the
    /// content size category for this view (and its subviews) to a minimum or a maximum value.
    /// You can use this to limit the support content size categories on part of your view hierarchy.
    /// Setting this to nil removes the limit on the minimum or maximum.
    /// Limits will be applied immediately and when future content size category updates occur.
    ///
    /// Specifying a minimum limit that is greater than the maximum limit (or vice versa) will effectively
    /// only use the maximum limit.
    ///
    /// Example:
    ///
    ///     // limit the support content size categories between .medium and .accessibilityExtraLarge (included).
    ///     view.minimumContentSizeCategory = UIContentSizeCategoryMedium;
    ///     view.maximumContentSizeCategory = UIContentSizeCategoryAccessibilityExtraLarge;
    open var minimumContentSizeCategory: UIContentSizeCategory?

    open var maximumContentSizeCategory: UIContentSizeCategory?

    
    /// Will return a string with a log of all the superviews of this view, alongside with what
    /// content size category each view has and if that view has limits applied.
    /// This is for debugging purposes only.
    open var appliedContentSizeCategoryLimitsDescription: String { get }
}
